Drop all uses of GdkPixbufAnimation in the gtk APIs
authorAlexander Larsson <alexl@redhat.com>
Mon, 23 Oct 2017 14:39:44 +0000 (16:39 +0200)
committerAlexander Larsson <alexl@redhat.com>
Mon, 23 Oct 2017 14:56:49 +0000 (16:56 +0200)
These are basically animated gifs, and don't fit well in how
modern things animate.

14 files changed:
demos/gtk-demo/main.c
demos/gtk-demo/textview.c
docs/reference/gtk/gtk4-sections.txt
gtk/a11y/gtkimageaccessible.c
gtk/gtkcellrendererpixbuf.c
gtk/gtkentry.c
gtk/gtkiconhelper.c
gtk/gtkiconhelperprivate.h
gtk/gtkimage.c
gtk/gtkimage.h
gtk/gtkimagedefinition.c
gtk/gtkimagedefinitionprivate.h
tests/meson.build
tests/testanimation.c [deleted file]

index 49f368b65398bd260d14edebf9d9b2ebc78d7ac5..d7b29e1917c9b27a61487c627d878fb1e178a9c2 100644 (file)
@@ -556,8 +556,7 @@ add_data_tab (const gchar *demoname)
       resource_name = g_strconcat (resource_dir, "/", resources[i], NULL);
 
       widget = gtk_image_new_from_resource (resource_name);
-      if (gtk_image_get_surface (GTK_IMAGE (widget)) == NULL &&
-          gtk_image_get_animation (GTK_IMAGE (widget)) == NULL)
+      if (gtk_image_get_surface (GTK_IMAGE (widget)) == NULL)
         {
           GBytes *bytes;
 
index 49cba65505170e4d6490a0c62eb8dd82bf2d0433..1e7b7263e440d6a5e1dedc890c317c3c2046e1c2 100644 (file)
@@ -363,8 +363,6 @@ insert_text (GtkTextBuffer *buffer)
   gtk_text_buffer_create_child_anchor (buffer, &iter);
   gtk_text_buffer_insert (buffer, &iter, " and a scale: ", -1);
   gtk_text_buffer_create_child_anchor (buffer, &iter);
-  gtk_text_buffer_insert (buffer, &iter, " and an animation: ", -1);
-  gtk_text_buffer_create_child_anchor (buffer, &iter);
   gtk_text_buffer_insert (buffer, &iter, " finally a text entry: ", -1);
   gtk_text_buffer_create_child_anchor (buffer, &iter);
   gtk_text_buffer_insert (buffer, &iter, ".\n", -1);
@@ -435,10 +433,6 @@ attach_widgets (GtkTextView *text_view)
           gtk_widget_set_size_request (widget, 70, -1);
         }
       else if (i == 3)
-        {
-          widget = gtk_image_new_from_resource ("/textview/floppybuddy.gif");
-        }
-      else if (i == 4)
         {
           widget = gtk_entry_new ();
         }
index 683f3b33e04a4cda00759786586babfd230f4439..5951c4681fab9b6ce409d6861c5a991c3d16c1f3 100644 (file)
@@ -1487,20 +1487,17 @@ GtkIconViewPrivate
 GtkImage
 GtkImageType
 gtk_image_get_surface
-gtk_image_get_animation
 gtk_image_get_icon_name
 gtk_image_get_gicon
 gtk_image_get_storage_type
 gtk_image_new_from_file
 gtk_image_new_from_pixbuf
-gtk_image_new_from_animation
 gtk_image_new_from_icon_name
 gtk_image_new_from_gicon
 gtk_image_new_from_resource
 gtk_image_new_from_surface
 gtk_image_set_from_file
 gtk_image_set_from_pixbuf
-gtk_image_set_from_animation
 gtk_image_set_from_icon_name
 gtk_image_set_from_gicon
 gtk_image_set_from_resource
index 3d603883dfccefe640cff7dfae4758a991cbc239..be2a3c57616950042939ce8485286ec449e3a0e9 100644 (file)
@@ -288,15 +288,6 @@ gtk_image_accessible_get_image_size (AtkImage *image,
         gtk_icon_size_lookup (size, width, height);
         break;
       }
-    case GTK_IMAGE_ANIMATION:
-      {
-        GdkPixbufAnimation *animation;
-
-        animation = gtk_image_get_animation (gtk_image);
-        *height = gdk_pixbuf_animation_get_height (animation);
-        *width = gdk_pixbuf_animation_get_width (animation);
-        break;
-      }
     case GTK_IMAGE_EMPTY:
     default:
       {
index 1e64f161e5ad584e31e9d57b7540b2a5b62a7c94..b53fe04389d0c4ed34f1a1fee2d71780b0c5ecce 100644 (file)
@@ -302,7 +302,6 @@ notify_storage_type (GtkCellRendererPixbuf *cellpixbuf,
       g_object_notify (G_OBJECT (cellpixbuf), "gicon");
       break;
     default:
-    case GTK_IMAGE_ANIMATION:
       g_assert_not_reached ();
     case GTK_IMAGE_EMPTY:
       break;
index b55ab5804b12b5a5c977e3c520db3deb7b080f94..ff927c9a703201dc73ffcf95ce6a610594a4b66d 100644 (file)
@@ -6642,7 +6642,6 @@ gtk_entry_clear_icon (GtkEntry             *entry,
       break;
 
     case GTK_IMAGE_EMPTY:
-    case GTK_IMAGE_ANIMATION:
     default:
       g_assert_not_reached ();
       break;
index 5918f28d0fd395a587a19f256ad9bf99cbe8d20d..d701e1718680f76f0770826a3ee02401b6231c00 100644 (file)
@@ -348,7 +348,6 @@ gtk_icon_helper_load_surface (GtkIconHelper   *self,
                                           gtk_image_definition_get_gicon (self->def));
       break;
 
-    case GTK_IMAGE_ANIMATION:
     case GTK_IMAGE_EMPTY:
     default:
       surface = NULL;
@@ -405,7 +404,6 @@ find_cached_texture (GtkIconHelper *self)
         gicon = g_themed_icon_new (gtk_image_definition_get_icon_name (self->def));
       break;
     case GTK_IMAGE_EMPTY:
-    case GTK_IMAGE_ANIMATION:
     case GTK_IMAGE_SURFACE:
     default:
       return NULL;
@@ -495,14 +493,6 @@ _gtk_icon_helper_get_size (GtkIconHelper *self,
                         &height);
       break;
 
-    case GTK_IMAGE_ANIMATION:
-      {
-        GdkPixbufAnimation *animation = gtk_image_definition_get_animation (self->def);
-        width = gdk_pixbuf_animation_get_width (animation);
-        height = gdk_pixbuf_animation_get_height (animation);
-        break;
-      }
-
     case GTK_IMAGE_ICON_NAME:
     case GTK_IMAGE_GICON:
       if (self->pixel_size != -1 || self->force_scale_pixbuf)
@@ -564,13 +554,6 @@ _gtk_icon_helper_set_icon_name (GtkIconHelper *self,
   _gtk_icon_helper_set_icon_size (self, icon_size);
 }
 
-void
-_gtk_icon_helper_set_animation (GtkIconHelper *self,
-                                GdkPixbufAnimation *animation)
-{
-  gtk_icon_helper_take_definition (self, gtk_image_definition_new_animation (animation, 1));
-}
-
 void
 _gtk_icon_helper_set_surface (GtkIconHelper *self,
                              cairo_surface_t *surface)
@@ -653,12 +636,6 @@ _gtk_icon_helper_peek_gicon (GtkIconHelper *self)
   return gtk_image_definition_get_gicon (self->def);
 }
 
-GdkPixbufAnimation *
-_gtk_icon_helper_peek_animation (GtkIconHelper *self)
-{
-  return gtk_image_definition_get_animation (self->def);
-}
-
 cairo_surface_t *
 _gtk_icon_helper_peek_surface (GtkIconHelper *self)
 {
@@ -732,24 +709,3 @@ _gtk_icon_helper_set_force_scale_pixbuf (GtkIconHelper *self,
       gtk_icon_helper_invalidate (self);
     }
 }
-
-void 
-_gtk_icon_helper_set_pixbuf_scale (GtkIconHelper *self,
-                                  int scale)
-{
-  switch (gtk_image_definition_get_storage_type (self->def))
-  {
-    case GTK_IMAGE_ANIMATION:
-      gtk_icon_helper_take_definition (self,
-                                      gtk_image_definition_new_animation (gtk_image_definition_get_animation (self->def),
-                                                                          scale));
-      break;
-
-    case GTK_IMAGE_EMPTY:
-    case GTK_IMAGE_ICON_NAME:
-    case GTK_IMAGE_GICON:
-    case GTK_IMAGE_SURFACE:
-    default:
-      break;
-  }
-}
index d439e360c24be67ad11f28ec7e28db351c6a5c63..91ec6d978e12f67c9af25ff3709c9e515476d128 100644 (file)
@@ -64,10 +64,6 @@ void _gtk_icon_helper_set_definition (GtkIconHelper *self,
 void _gtk_icon_helper_set_gicon (GtkIconHelper *self,
                                  GIcon *gicon,
                                  GtkIconSize icon_size);
-void _gtk_icon_helper_set_pixbuf_scale (GtkIconHelper *self,
-                                       int scale);
-void _gtk_icon_helper_set_animation (GtkIconHelper *self,
-                                     GdkPixbufAnimation *animation);
 
 void _gtk_icon_helper_set_icon_name (GtkIconHelper *self,
                                      const gchar *icon_name,
@@ -88,7 +84,6 @@ gint _gtk_icon_helper_get_pixel_size (GtkIconHelper *self);
 gboolean _gtk_icon_helper_get_use_fallback (GtkIconHelper *self);
 
 GIcon *_gtk_icon_helper_peek_gicon (GtkIconHelper *self);
-GdkPixbufAnimation *_gtk_icon_helper_peek_animation (GtkIconHelper *self);
 cairo_surface_t *_gtk_icon_helper_peek_surface (GtkIconHelper *self);
 
 GtkImageDefinition *gtk_icon_helper_get_definition (GtkIconHelper *self);
index a5ad986f8a10e38adeacf5ab6cb47fa1bc3db74e..c76bcb954c889abc03e4609c10fbf961bf11c5a0 100644 (file)
@@ -61,9 +61,6 @@
  * gdk_pixbuf_new_from_file(), then create the #GtkImage with
  * gtk_image_new_from_pixbuf().
  *
- * The image file may contain an animation, if so the #GtkImage will
- * display an animation (#GdkPixbufAnimation) instead of a static image.
- *
  * Sometimes an application will want to avoid depending on external data
  * files, such as image files. See the documentation of #GResource for details.
  * In this case, the #GtkImage:resource, gtk_image_new_from_resource() and
@@ -79,12 +76,9 @@ struct _GtkImagePrivate
 {
   GtkIconHelper icon_helper;
 
-  GdkPixbufAnimationIter *animation_iter;
-  gint animation_timeout;
-
   float baseline_align;
 
-  gchar                *filename;       /* Only used with GTK_IMAGE_ANIMATION, GTK_IMAGE_SURFACE */
+  gchar                *filename;       /* Only used with GTK_IMAGE_SURFACE */
   gchar                *resource_path;  /* Only used with GTK_IMAGE_SURFACE */
 };
 
@@ -96,7 +90,6 @@ static void gtk_image_size_allocate        (GtkWidget           *widget,
                                             const GtkAllocation *allocation,
                                             int                  baseline,
                                             GtkAllocation       *out_clip);
-static void gtk_image_unmap                (GtkWidget    *widget);
 static void gtk_image_unrealize            (GtkWidget    *widget);
 static void gtk_image_measure (GtkWidget      *widget,
                                GtkOrientation  orientation,
@@ -125,7 +118,6 @@ enum
   PROP_FILE,
   PROP_ICON_SIZE,
   PROP_PIXEL_SIZE,
-  PROP_PIXBUF_ANIMATION,
   PROP_ICON_NAME,
   PROP_STORAGE_TYPE,
   PROP_GICON,
@@ -154,7 +146,6 @@ gtk_image_class_init (GtkImageClass *class)
   widget_class->snapshot = gtk_image_snapshot;
   widget_class->measure = gtk_image_measure;
   widget_class->size_allocate = gtk_image_size_allocate;
-  widget_class->unmap = gtk_image_unmap;
   widget_class->unrealize = gtk_image_unrealize;
   widget_class->style_updated = gtk_image_style_updated;
 
@@ -197,13 +188,6 @@ gtk_image_class_init (GtkImageClass *class)
                         -1,
                         GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
 
-  image_props[PROP_PIXBUF_ANIMATION] =
-      g_param_spec_object ("pixbuf-animation",
-                           P_("Animation"),
-                           P_("GdkPixbufAnimation to display"),
-                           GDK_TYPE_PIXBUF_ANIMATION,
-                           GTK_PARAM_READWRITE);
-
   /**
    * GtkImage:icon-name:
    *
@@ -338,9 +322,6 @@ gtk_image_set_property (GObject      *object,
     case PROP_PIXEL_SIZE:
       gtk_image_set_pixel_size (image, g_value_get_int (value));
       break;
-    case PROP_PIXBUF_ANIMATION:
-      gtk_image_set_from_animation (image, g_value_get_object (value));
-      break;
     case PROP_ICON_NAME:
       gtk_image_set_from_icon_name (image, g_value_get_string (value), icon_size);
       break;
@@ -385,9 +366,6 @@ gtk_image_get_property (GObject     *object,
     case PROP_PIXEL_SIZE:
       g_value_set_int (value, _gtk_icon_helper_get_pixel_size (&priv->icon_helper));
       break;
-    case PROP_PIXBUF_ANIMATION:
-      g_value_set_object (value, _gtk_icon_helper_peek_animation (&priv->icon_helper));
-      break;
     case PROP_ICON_NAME:
       g_value_set_string (value, _gtk_icon_helper_get_icon_name (&priv->icon_helper));
       break;
@@ -419,13 +397,9 @@ gtk_image_get_property (GObject     *object,
  * display a “broken image” icon. This function never returns %NULL,
  * it always returns a valid #GtkImage widget.
  *
- * If the file contains an animation, the image will contain an
- * animation.
- *
  * If you need to detect failures to load the file, use
  * gdk_pixbuf_new_from_file() to load the file yourself, then create
- * the #GtkImage from the surface. (Or for animations, use
- * gdk_pixbuf_animation_new_from_file()).
+ * the #GtkImage from the surface.
  *
  * The storage type (gtk_image_get_storage_type()) of the returned
  * image is not defined, it will be whatever is appropriate for
@@ -454,13 +428,9 @@ gtk_image_new_from_file   (const gchar *filename)
  * display a “broken image” icon. This function never returns %NULL,
  * it always returns a valid #GtkImage widget.
  *
- * If the file contains an animation, the image will contain an
- * animation.
- *
  * If you need to detect failures to load the file, use
  * gdk_pixbuf_new_from_file() to load the file yourself, then create
- * the #GtkImage from the pixbuf. (Or for animations, use
- * gdk_pixbuf_animation_new_from_file()).
+ * the #GtkImage from the pixbuf.
  *
  * The storage type (gtk_image_get_storage_type()) of the returned
  * image is not defined, it will be whatever is appropriate for
@@ -537,36 +507,6 @@ gtk_image_new_from_surface (cairo_surface_t *surface)
   return GTK_WIDGET (image);
 }
 
-/**
- * gtk_image_new_from_animation:
- * @animation: an animation
- * 
- * Creates a #GtkImage displaying the given animation.
- * The #GtkImage does not assume a reference to the
- * animation; you still need to unref it if you own references.
- * #GtkImage will add its own reference rather than adopting yours.
- *
- * Note that the animation frames are shown using a timeout with
- * #G_PRIORITY_DEFAULT. When using animations to indicate busyness,
- * keep in mind that the animation will only be shown if the main loop
- * is not busy with something that has a higher priority.
- *
- * Returns: a new #GtkImage widget
- **/
-GtkWidget*
-gtk_image_new_from_animation (GdkPixbufAnimation *animation)
-{
-  GtkImage *image;
-
-  g_return_val_if_fail (GDK_IS_PIXBUF_ANIMATION (animation), NULL);
-  
-  image = g_object_new (GTK_TYPE_IMAGE, NULL);
-
-  gtk_image_set_from_animation (image, animation);
-
-  return GTK_WIDGET (image);
-}
-
 /**
  * gtk_image_new_from_icon_name:
  * @icon_name: (nullable): an icon name or %NULL
@@ -725,7 +665,8 @@ gtk_image_set_from_file   (GtkImage    *image,
   GtkImagePrivate *priv = gtk_image_get_instance_private (image);
   GdkPixbufAnimation *anim;
   gint scale_factor;
-  
+  cairo_surface_t *surface;
+
   g_return_if_fail (GTK_IS_IMAGE (image));
 
   g_object_freeze_notify (G_OBJECT (image));
@@ -750,23 +691,10 @@ gtk_image_set_from_file   (GtkImage    *image,
       return;
     }
 
-  /* We could just unconditionally set_from_animation,
-   * but it's nicer for memory if we toss the animation
-   * if it's just a single pixbuf
-   */
-
-  if (gdk_pixbuf_animation_is_static_image (anim))
-    {
-      cairo_surface_t *surface = gdk_cairo_surface_create_from_pixbuf (gdk_pixbuf_animation_get_static_image (anim),
-                                                                       scale_factor, _gtk_widget_get_window (GTK_WIDGET (image)));
-      gtk_image_set_from_surface (image, surface);
-      cairo_surface_destroy (surface);
-    }
-  else
-    {
-      gtk_image_set_from_animation (image, anim);
-      _gtk_icon_helper_set_pixbuf_scale (&priv->icon_helper, scale_factor);
-    }
+  surface = gdk_cairo_surface_create_from_pixbuf (gdk_pixbuf_animation_get_static_image (anim),
+                                                  scale_factor, _gtk_widget_get_window (GTK_WIDGET (image)));
+  gtk_image_set_from_surface (image, surface);
+  cairo_surface_destroy (surface);
 
   g_object_unref (anim);
 
@@ -819,6 +747,7 @@ gtk_image_set_from_resource (GtkImage    *image,
   GtkImagePrivate *priv = gtk_image_get_instance_private (image);
   GdkPixbufAnimation *animation;
   gint scale_factor = 1;
+  cairo_surface_t *surface;
 
   g_return_if_fail (GTK_IS_IMAGE (image));
 
@@ -851,18 +780,10 @@ gtk_image_set_from_resource (GtkImage    *image,
       return;
     }
 
-  if (gdk_pixbuf_animation_is_static_image (animation))
-    {
-      cairo_surface_t *surface = gdk_cairo_surface_create_from_pixbuf (gdk_pixbuf_animation_get_static_image (animation),
-                                                                       scale_factor, _gtk_widget_get_window (GTK_WIDGET (image)));
-      gtk_image_set_from_surface (image, surface);
-      cairo_surface_destroy (surface);
-    }
-  else
-    {
-      gtk_image_set_from_animation (image, animation);
-      _gtk_icon_helper_set_pixbuf_scale (&priv->icon_helper, scale_factor);
-    }
+  surface = gdk_cairo_surface_create_from_pixbuf (gdk_pixbuf_animation_get_static_image (animation),
+                                                  scale_factor, _gtk_widget_get_window (GTK_WIDGET (image)));
+  gtk_image_set_from_surface (image, surface);
+  cairo_surface_destroy (surface);
 
   priv->resource_path = g_strdup (resource_path);
 
@@ -905,42 +826,6 @@ gtk_image_set_from_pixbuf (GtkImage  *image,
     cairo_surface_destroy (surface);
 }
 
-/**
- * gtk_image_set_from_animation:
- * @image: a #GtkImage
- * @animation: the #GdkPixbufAnimation
- * 
- * Causes the #GtkImage to display the given animation (or display
- * nothing, if you set the animation to %NULL).
- **/
-void
-gtk_image_set_from_animation (GtkImage           *image,
-                              GdkPixbufAnimation *animation)
-{
-  GtkImagePrivate *priv = gtk_image_get_instance_private (image);
-
-  g_return_if_fail (GTK_IS_IMAGE (image));
-  g_return_if_fail (animation == NULL ||
-                    GDK_IS_PIXBUF_ANIMATION (animation));
-
-  g_object_freeze_notify (G_OBJECT (image));
-  
-  if (animation)
-    g_object_ref (animation);
-
-  gtk_image_clear (image);
-
-  if (animation != NULL)
-    {
-      _gtk_icon_helper_set_animation (&priv->icon_helper, animation);
-      g_object_unref (animation);
-    }
-
-  g_object_notify_by_pspec (G_OBJECT (image), image_props[PROP_PIXBUF_ANIMATION]);
-
-  g_object_thaw_notify (G_OBJECT (image));
-}
-
 /**
  * gtk_image_set_from_icon_name:
  * @image: a #GtkImage
@@ -1090,29 +975,6 @@ gtk_image_get_surface (GtkImage *image)
   return _gtk_icon_helper_peek_surface (&priv->icon_helper);
 }
 
-/**
- * gtk_image_get_animation:
- * @image: a #GtkImage
- *
- * Gets the #GdkPixbufAnimation being displayed by the #GtkImage.
- * The storage type of the image must be %GTK_IMAGE_EMPTY or
- * %GTK_IMAGE_ANIMATION (see gtk_image_get_storage_type()).
- * The caller of this function does not own a reference to the
- * returned animation.
- * 
- * Returns: (nullable) (transfer none): the displayed animation, or %NULL if
- * the image is empty
- **/
-GdkPixbufAnimation*
-gtk_image_get_animation (GtkImage *image)
-{
-  GtkImagePrivate *priv = gtk_image_get_instance_private (image);
-
-  g_return_val_if_fail (GTK_IS_IMAGE (image), NULL);
-
-  return _gtk_icon_helper_peek_animation (&priv->icon_helper);
-}
-
 /**
  * gtk_image_get_icon_name:
  * @image: a #GtkImage
@@ -1190,24 +1052,6 @@ gtk_image_new (void)
   return g_object_new (GTK_TYPE_IMAGE, NULL);
 }
 
-static void
-gtk_image_reset_anim_iter (GtkImage *image)
-{
-  GtkImagePrivate *priv = gtk_image_get_instance_private (image);
-
-  if (gtk_image_get_storage_type (image) == GTK_IMAGE_ANIMATION)
-    {
-      /* Reset the animation */
-      if (priv->animation_timeout)
-        {
-          g_source_remove (priv->animation_timeout);
-          priv->animation_timeout = 0;
-        }
-
-      g_clear_object (&priv->animation_iter);
-    }
-}
-
 static void
 gtk_image_size_allocate (GtkWidget           *widget,
                          const GtkAllocation *allocation,
@@ -1222,79 +1066,17 @@ gtk_image_size_allocate (GtkWidget           *widget,
                                        allocation->height);
 }
 
-static void
-gtk_image_unmap (GtkWidget *widget)
-{
-  gtk_image_reset_anim_iter (GTK_IMAGE (widget));
-
-  GTK_WIDGET_CLASS (gtk_image_parent_class)->unmap (widget);
-}
-
 static void
 gtk_image_unrealize (GtkWidget *widget)
 {
   GtkImage *image = GTK_IMAGE (widget);
   GtkImagePrivate *priv = gtk_image_get_instance_private (image);
 
-  gtk_image_reset_anim_iter (image);
-
   gtk_icon_helper_invalidate (&priv->icon_helper);
 
   GTK_WIDGET_CLASS (gtk_image_parent_class)->unrealize (widget);
 }
 
-static gint
-animation_timeout (gpointer data)
-{
-  GtkImage *image = GTK_IMAGE (data);
-  GtkImagePrivate *priv = gtk_image_get_instance_private (image);
-  int delay;
-
-  priv->animation_timeout = 0;
-
-  gdk_pixbuf_animation_iter_advance (priv->animation_iter, NULL);
-
-  delay = gdk_pixbuf_animation_iter_get_delay_time (priv->animation_iter);
-  if (delay >= 0)
-    {
-      GtkWidget *widget = GTK_WIDGET (image);
-
-      priv->animation_timeout =
-        gdk_threads_add_timeout (delay, animation_timeout, image);
-      g_source_set_name_by_id (priv->animation_timeout, "[gtk+] animation_timeout");
-
-      gtk_widget_queue_draw (widget);
-    }
-
-  return FALSE;
-}
-
-static GdkPixbuf *
-get_animation_frame (GtkImage *image)
-{
-  GtkImagePrivate *priv = gtk_image_get_instance_private (image);
-
-  if (priv->animation_iter == NULL)
-    {
-      int delay;
-
-      priv->animation_iter = 
-        gdk_pixbuf_animation_get_iter (_gtk_icon_helper_peek_animation (&priv->icon_helper), NULL);
-
-      delay = gdk_pixbuf_animation_iter_get_delay_time (priv->animation_iter);
-      if (delay >= 0) {
-        priv->animation_timeout =
-          gdk_threads_add_timeout (delay, animation_timeout, image);
-        g_source_set_name_by_id (priv->animation_timeout, "[gtk+] animation_timeout");
-      }
-    }
-
-  /* don't advance the anim iter here, or we could get frame changes between two
-   * exposes of different areas.
-   */
-  return g_object_ref (gdk_pixbuf_animation_iter_get_pixbuf (priv->animation_iter));
-}
-
 static float
 gtk_image_get_baseline_align (GtkImage *image)
 {
@@ -1343,21 +1125,9 @@ gtk_image_snapshot (GtkWidget   *widget,
 
   x += (width - w) / 2;
 
-  if (gtk_image_get_storage_type (image) == GTK_IMAGE_ANIMATION)
-    {
-      GtkStyleContext *context = gtk_widget_get_style_context (widget);
-      GdkPixbuf *pixbuf = get_animation_frame (image);
-
-      gtk_snapshot_render_icon (snapshot, context, pixbuf, x, y);
-
-      g_object_unref (pixbuf);
-    }
-  else
-    {
-      gtk_snapshot_offset (snapshot, x, y);
-      gtk_icon_helper_snapshot (&priv->icon_helper, snapshot);
-      gtk_snapshot_offset (snapshot, -x, -y);
-    }
+  gtk_snapshot_offset (snapshot, x, y);
+  gtk_icon_helper_snapshot (&priv->icon_helper, snapshot);
+  gtk_snapshot_offset (snapshot, -x, -y);
 }
 
 static void
@@ -1366,9 +1136,6 @@ gtk_image_notify_for_storage_type (GtkImage     *image,
 {
   switch (storage_type)
     {
-    case GTK_IMAGE_ANIMATION:
-      g_object_notify_by_pspec (G_OBJECT (image), image_props[PROP_PIXBUF_ANIMATION]);
-      break;
     case GTK_IMAGE_ICON_NAME:
       g_object_notify_by_pspec (G_OBJECT (image), image_props[PROP_ICON_NAME]);
       break;
@@ -1439,8 +1206,6 @@ gtk_image_clear (GtkImage *image)
 
   g_object_notify_by_pspec (G_OBJECT (image), image_props[PROP_ICON_SIZE]);
 
-  gtk_image_reset_anim_iter (image);
-
   gtk_image_notify_for_storage_type (image, storage_type);
 
   if (priv->filename)
index 67bbcb387f3232b0e7594fced08b082fcb297933..de270b1f8eb9bf8c0aab10a6dfbfacd7e1672e72 100644 (file)
@@ -51,7 +51,6 @@ typedef struct _GtkImageClass         GtkImageClass;
 /**
  * GtkImageType:
  * @GTK_IMAGE_EMPTY: there is no image displayed by the widget
- * @GTK_IMAGE_ANIMATION: the widget contains a #GdkPixbufAnimation
  * @GTK_IMAGE_ICON_NAME: the widget contains a named icon.
  *  This image type was added in GTK+ 2.6
  * @GTK_IMAGE_GICON: the widget contains a #GIcon.
@@ -70,7 +69,6 @@ typedef struct _GtkImageClass         GtkImageClass;
 typedef enum
 {
   GTK_IMAGE_EMPTY,
-  GTK_IMAGE_ANIMATION,
   GTK_IMAGE_ICON_NAME,
   GTK_IMAGE_GICON,
   GTK_IMAGE_SURFACE
@@ -110,8 +108,6 @@ GtkWidget* gtk_image_new_from_resource  (const gchar     *resource_path);
 GDK_AVAILABLE_IN_ALL
 GtkWidget* gtk_image_new_from_pixbuf    (GdkPixbuf       *pixbuf);
 GDK_AVAILABLE_IN_ALL
-GtkWidget* gtk_image_new_from_animation (GdkPixbufAnimation *animation);
-GDK_AVAILABLE_IN_ALL
 GtkWidget* gtk_image_new_from_icon_name (const gchar     *icon_name,
                                         GtkIconSize      size);
 GDK_AVAILABLE_IN_ALL
@@ -132,9 +128,6 @@ GDK_AVAILABLE_IN_ALL
 void gtk_image_set_from_pixbuf    (GtkImage        *image,
                                    GdkPixbuf       *pixbuf);
 GDK_AVAILABLE_IN_ALL
-void gtk_image_set_from_animation (GtkImage           *image,
-                                   GdkPixbufAnimation *animation);
-GDK_AVAILABLE_IN_ALL
 void gtk_image_set_from_icon_name (GtkImage        *image,
                                   const gchar     *icon_name,
                                   GtkIconSize      size);
@@ -155,8 +148,6 @@ GtkImageType gtk_image_get_storage_type (GtkImage   *image);
 GDK_AVAILABLE_IN_3_94
 cairo_surface_t *gtk_image_get_surface (GtkImage *image);
 
-GDK_AVAILABLE_IN_ALL
-GdkPixbufAnimation* gtk_image_get_animation (GtkImage *image);
 GDK_AVAILABLE_IN_ALL
 void       gtk_image_get_icon_name (GtkImage     *image,
                                    const gchar **icon_name,
index 4cef0d5ad01371509293a36b87479852e534a8dc..f16006cb70220196f4ff3bdaa321ce281bca1b0f 100644 (file)
@@ -21,7 +21,6 @@
 
 typedef struct _GtkImageDefinitionEmpty GtkImageDefinitionEmpty;
 typedef struct _GtkImageDefinitionStock GtkImageDefinitionStock;
-typedef struct _GtkImageDefinitionAnimation GtkImageDefinitionAnimation;
 typedef struct _GtkImageDefinitionIconName GtkImageDefinitionIconName;
 typedef struct _GtkImageDefinitionGIcon GtkImageDefinitionGIcon;
 typedef struct _GtkImageDefinitionSurface GtkImageDefinitionSurface;
@@ -38,14 +37,6 @@ struct _GtkImageDefinitionStock {
   char *id;
 };
 
-struct _GtkImageDefinitionAnimation {
-  GtkImageType type;
-  gint ref_count;
-
-  GdkPixbufAnimation *animation;
-  int scale;
-};
-
 struct _GtkImageDefinitionIconName {
   GtkImageType type;
   gint ref_count;
@@ -72,7 +63,6 @@ union _GtkImageDefinition
   GtkImageType type;
   GtkImageDefinitionEmpty empty;
   GtkImageDefinitionStock stock;
-  GtkImageDefinitionAnimation animation;
   GtkImageDefinitionIconName icon_name;
   GtkImageDefinitionGIcon gicon;
   GtkImageDefinitionSurface surface;
@@ -92,7 +82,6 @@ gtk_image_definition_alloc (GtkImageType type)
   static gsize sizes[] = {
     sizeof (GtkImageDefinitionEmpty),
     sizeof (GtkImageDefinitionStock),
-    sizeof (GtkImageDefinitionAnimation),
     sizeof (GtkImageDefinitionIconName),
     sizeof (GtkImageDefinitionGIcon),
     sizeof (GtkImageDefinitionSurface)
@@ -108,22 +97,6 @@ gtk_image_definition_alloc (GtkImageType type)
   return def;
 }
 
-GtkImageDefinition *
-gtk_image_definition_new_animation (GdkPixbufAnimation *animation,
-                                    int                 scale)
-{
-  GtkImageDefinition *def;
-
-  if (animation == NULL || scale <= 0)
-    return NULL;
-
-  def = gtk_image_definition_alloc (GTK_IMAGE_ANIMATION);
-  def->animation.animation = g_object_ref (animation);
-  def->animation.scale = scale;
-
-  return def;
-}
-
 GtkImageDefinition *
 gtk_image_definition_new_icon_name (const char *icon_name)
 {
@@ -188,9 +161,6 @@ gtk_image_definition_unref (GtkImageDefinition *def)
     case GTK_IMAGE_EMPTY:
       g_assert_not_reached ();
       break;
-    case GTK_IMAGE_ANIMATION:
-      g_object_unref (def->animation.animation);
-      break;
     case GTK_IMAGE_SURFACE:
       cairo_surface_destroy (def->surface.surface);
       break;
@@ -223,20 +193,9 @@ gtk_image_definition_get_scale (const GtkImageDefinition *def)
     case GTK_IMAGE_ICON_NAME:
     case GTK_IMAGE_GICON:
       return 1;
-    case GTK_IMAGE_ANIMATION:
-      return def->animation.scale;
     }
 }
 
-GdkPixbufAnimation *
-gtk_image_definition_get_animation (const GtkImageDefinition *def)
-{
-  if (def->type != GTK_IMAGE_ANIMATION)
-    return NULL;
-
-  return def->animation.animation;
-}
-
 const gchar *
 gtk_image_definition_get_icon_name (const GtkImageDefinition *def)
 {
index 069da127e33da280e615b1ff5c2e7abcb757aed5..9acf7ce876b67456dee0edbb0389b04da92df102 100644 (file)
@@ -26,8 +26,6 @@ G_BEGIN_DECLS
 typedef union _GtkImageDefinition GtkImageDefinition;
 
 GtkImageDefinition *    gtk_image_definition_new_empty          (void);
-GtkImageDefinition *    gtk_image_definition_new_animation      (GdkPixbufAnimation             *animation,
-                                                                 int                             scale);
 GtkImageDefinition *    gtk_image_definition_new_icon_name      (const char                     *icon_name);
 GtkImageDefinition *    gtk_image_definition_new_gicon          (GIcon                          *gicon);
 GtkImageDefinition *    gtk_image_definition_new_surface        (cairo_surface_t                *surface);
@@ -37,7 +35,6 @@ void                    gtk_image_definition_unref              (GtkImageDefinit
 
 GtkImageType            gtk_image_definition_get_storage_type   (const GtkImageDefinition       *def);
 gint                    gtk_image_definition_get_scale          (const GtkImageDefinition       *def);
-GdkPixbufAnimation *    gtk_image_definition_get_animation      (const GtkImageDefinition       *def);
 const gchar *           gtk_image_definition_get_icon_name      (const GtkImageDefinition       *def);
 GIcon *                 gtk_image_definition_get_gicon          (const GtkImageDefinition       *def);
 cairo_surface_t *       gtk_image_definition_get_surface        (const GtkImageDefinition       *def);
index b4ae0bb6fdfb8fdaa88506b622b993550e93d790..ba6d090f6794772d79982ce02782bdcdbb1c6fbc 100644 (file)
@@ -109,7 +109,6 @@ gtk_tests = [
   ['testtreepos'],
   ['testsensitive'],
   ['testtextview'],
-  ['testanimation'],
   ['testpixbuf-scale'],
   ['testgmenu'],
   ['testlogout'],
diff --git a/tests/testanimation.c b/tests/testanimation.c
deleted file mode 100644 (file)
index 8190be9..0000000
+++ /dev/null
@@ -1,431 +0,0 @@
-
-/* testpixbuf -- test program for gdk-pixbuf code
- * Copyright (C) 1999 Mark Crichton, Larry Ewing
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "config.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <gtk/gtk.h>
-
-#ifndef G_OS_WIN32
-# include <unistd.h>
-#endif
-
-typedef struct _LoadContext LoadContext;
-
-struct _LoadContext
-{
-  gchar *filename;
-  GtkWidget *window;
-  GdkPixbufLoader *pixbuf_loader;
-  guint load_timeout;
-  FILE* image_stream;
-};
-
-static void
-destroy_context (gpointer data)
-{
-  LoadContext *lc = data;
-
-  g_free (lc->filename);
-  
-  if (lc->load_timeout)
-    g_source_remove (lc->load_timeout);
-
-  if (lc->image_stream)
-    fclose (lc->image_stream);
-
-  if (lc->pixbuf_loader)
-    {
-      gdk_pixbuf_loader_close (lc->pixbuf_loader, NULL);
-      g_object_unref (lc->pixbuf_loader);
-    }
-  
-  g_free (lc);
-}
-
-static LoadContext*
-get_load_context (GtkWidget *image)
-{
-  LoadContext *lc;
-
-  lc = g_object_get_data (G_OBJECT (image), "lc");
-
-  if (lc == NULL)
-    {
-      lc = g_new0 (LoadContext, 1);
-
-      g_object_set_data_full (G_OBJECT (image),        
-                              "lc",
-                              lc,
-                              destroy_context);
-    }
-
-  return lc;
-}
-
-static void
-progressive_prepared_callback (GdkPixbufLoader* loader,
-                               gpointer         data)
-{
-  GdkPixbuf* pixbuf;
-  GtkWidget* image;
-
-  image = GTK_WIDGET (data);
-    
-  pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
-
-  /* Avoid displaying random memory contents, since the pixbuf
-   * isn't filled in yet.
-   */
-  gdk_pixbuf_fill (pixbuf, 0xaaaaaaff);
-
-  /* Could set the pixbuf instead, if we only wanted to display
-   * static images.
-   */
-  gtk_image_set_from_animation (GTK_IMAGE (image),
-                                gdk_pixbuf_loader_get_animation (loader));
-}
-
-static void
-progressive_updated_callback (GdkPixbufLoader* loader,
-                              gint x, gint y, gint width, gint height,
-                              gpointer data)
-{
-  GtkWidget* image;
-  
-  image = GTK_WIDGET (data);
-
-  /* We know the pixbuf inside the GtkImage has changed, but the image
-   * itself doesn't know this; so queue a redraw.  If we wanted to be
-   * really efficient, we could use a drawing area or something
-   * instead of a GtkImage, so we could control the exact position of
-   * the pixbuf on the display, then we could queue a draw for only
-   * the updated area of the image.
-   */
-
-  /* We only really need to redraw if the image's animation iterator
-   * is gdk_pixbuf_animation_iter_on_currently_loading_frame(), but
-   * who cares.
-   */
-  
-  gtk_widget_queue_draw (image);
-}
-
-static gint
-progressive_timeout (gpointer data)
-{
-  GtkWidget *image;
-  LoadContext *lc;
-  
-  image = GTK_WIDGET (data);
-  lc = get_load_context (image);
-  
-  /* This shows off fully-paranoid error handling, so looks scary.
-   * You could factor out the error handling code into a nice separate
-   * function to make things nicer.
-   */
-  
-  if (lc->image_stream)
-    {
-      size_t bytes_read;
-      guchar buf[256];
-      GError *error = NULL;
-      
-      bytes_read = fread (buf, 1, 256, lc->image_stream);
-
-      if (ferror (lc->image_stream))
-        {
-          GtkWidget *dialog;
-          
-          dialog = gtk_message_dialog_new (GTK_WINDOW (lc->window),
-                                           GTK_DIALOG_DESTROY_WITH_PARENT,
-                                           GTK_MESSAGE_ERROR,
-                                           GTK_BUTTONS_CLOSE,
-                                           "Failure reading image file 'alphatest.png': %s",
-                                           g_strerror (errno));
-
-          g_signal_connect (dialog, "response",
-                           G_CALLBACK (gtk_widget_destroy), NULL);
-
-          fclose (lc->image_stream);
-          lc->image_stream = NULL;
-
-          gtk_widget_show (dialog);
-          
-          lc->load_timeout = 0;
-
-          return FALSE; /* uninstall the timeout */
-        }
-
-      if (!gdk_pixbuf_loader_write (lc->pixbuf_loader,
-                                    buf, bytes_read,
-                                    &error))
-        {
-          GtkWidget *dialog;
-          
-          dialog = gtk_message_dialog_new (GTK_WINDOW (lc->window),
-                                           GTK_DIALOG_DESTROY_WITH_PARENT,
-                                           GTK_MESSAGE_ERROR,
-                                           GTK_BUTTONS_CLOSE,
-                                           "Failed to load image: %s",
-                                           error->message);
-
-          g_error_free (error);
-          
-          g_signal_connect (dialog, "response",
-                           G_CALLBACK (gtk_widget_destroy), NULL);
-
-          fclose (lc->image_stream);
-          lc->image_stream = NULL;
-          
-          gtk_widget_show (dialog);
-
-          lc->load_timeout = 0;
-
-          return FALSE; /* uninstall the timeout */
-        }
-
-      if (feof (lc->image_stream))
-        {
-          fclose (lc->image_stream);
-          lc->image_stream = NULL;
-
-          /* Errors can happen on close, e.g. if the image
-           * file was truncated we'll know on close that
-           * it was incomplete.
-           */
-          error = NULL;
-          if (!gdk_pixbuf_loader_close (lc->pixbuf_loader,
-                                        &error))
-            {
-              GtkWidget *dialog;
-              
-              dialog = gtk_message_dialog_new (GTK_WINDOW (lc->window),
-                                               GTK_DIALOG_DESTROY_WITH_PARENT,
-                                               GTK_MESSAGE_ERROR,
-                                               GTK_BUTTONS_CLOSE,
-                                               "Failed to load image: %s",
-                                               error->message);
-              
-              g_error_free (error);
-              
-              g_signal_connect (dialog, "response",
-                               G_CALLBACK (gtk_widget_destroy), NULL);
-              
-              gtk_widget_show (dialog);
-
-              g_object_unref (lc->pixbuf_loader);
-              lc->pixbuf_loader = NULL;
-              
-              lc->load_timeout = 0;
-              
-              return FALSE; /* uninstall the timeout */
-            }
-          
-          g_object_unref (lc->pixbuf_loader);
-          lc->pixbuf_loader = NULL;
-        }
-    }
-  else
-    {
-      lc->image_stream = fopen (lc->filename, "r");
-
-      if (lc->image_stream == NULL)
-        {
-          GtkWidget *dialog;
-          
-          dialog = gtk_message_dialog_new (GTK_WINDOW (lc->window),
-                                           GTK_DIALOG_DESTROY_WITH_PARENT,
-                                           GTK_MESSAGE_ERROR,
-                                           GTK_BUTTONS_CLOSE,
-                                           "Unable to open image file '%s': %s",
-                                           lc->filename,
-                                           g_strerror (errno));
-
-          g_signal_connect (dialog, "response",
-                           G_CALLBACK (gtk_widget_destroy), NULL);
-          
-          gtk_widget_show (dialog);
-
-          lc->load_timeout = 0;
-
-          return FALSE; /* uninstall the timeout */
-        }
-
-      if (lc->pixbuf_loader)
-        {
-          gdk_pixbuf_loader_close (lc->pixbuf_loader, NULL);
-          g_object_unref (lc->pixbuf_loader);
-          lc->pixbuf_loader = NULL;
-        }
-      
-      lc->pixbuf_loader = gdk_pixbuf_loader_new ();
-      
-      g_signal_connect (lc->pixbuf_loader, "area_prepared",
-                       G_CALLBACK (progressive_prepared_callback), image);
-      g_signal_connect (lc->pixbuf_loader, "area_updated",
-                       G_CALLBACK (progressive_updated_callback), image);
-    }
-
-  /* leave timeout installed */
-  return TRUE;
-}
-
-static void
-start_progressive_loading (GtkWidget *image)
-{
-  LoadContext *lc;
-
-  lc = get_load_context (image);
-  
-  /* This is obviously totally contrived (we slow down loading
-   * on purpose to show how incremental loading works).
-   * The real purpose of incremental loading is the case where
-   * you are reading data from a slow source such as the network.
-   * The timeout simply simulates a slow data source by inserting
-   * pauses in the reading process.
-   */
-  lc->load_timeout = gdk_threads_add_timeout (100,
-                                    progressive_timeout,
-                                    image);
-}
-
-static GtkWidget *
-do_image (const char *filename)
-{
-  GtkWidget *frame;
-  GtkWidget *vbox;
-  GtkWidget *image;
-  GtkWidget *label;
-  GtkWidget *window;
-  gchar *str, *escaped;
-  LoadContext *lc;
-  
-  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
-  gtk_window_set_title (GTK_WINDOW (window), "Image Loading");
-
-  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
-  gtk_container_add (GTK_CONTAINER (window), vbox);
-
-  label = gtk_label_new (NULL);
-  gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
-  escaped = g_markup_escape_text (filename, -1);
-  str = g_strdup_printf ("Progressively loading: <b>%s</b>", escaped);
-  gtk_label_set_markup (GTK_LABEL (label),
-                        str);
-  g_free (escaped);
-  g_free (str);
-
-  gtk_box_pack_start (GTK_BOX (vbox), label);
-
-  frame = gtk_frame_new (NULL);
-  gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
-  gtk_widget_set_halign (frame, GTK_ALIGN_CENTER);
-  gtk_widget_set_valign (frame, GTK_ALIGN_CENTER);
-  gtk_box_pack_start (GTK_BOX (vbox), frame);
-
-  image = gtk_image_new_from_pixbuf (NULL);
-  gtk_container_add (GTK_CONTAINER (frame), image);
-
-  lc = get_load_context (image);
-
-  lc->window = window;
-  lc->filename = g_strdup (filename);
-  
-  start_progressive_loading (image);
-
-  g_signal_connect (window, "destroy",
-                   G_CALLBACK (gtk_main_quit), NULL);
-  
-  g_signal_connect (window, "delete_event",
-                   G_CALLBACK (gtk_main_quit), NULL);
-
-  gtk_widget_show (window);
-
-  return window;
-}
-
-static void
-do_nonprogressive (const gchar *filename)
-{
-  GtkWidget *frame;
-  GtkWidget *vbox;
-  GtkWidget *image;
-  GtkWidget *label;
-  GtkWidget *window;
-  gchar *str, *escaped;
-  
-  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
-  gtk_window_set_title (GTK_WINDOW (window), "Animation");
-
-  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
-  gtk_container_add (GTK_CONTAINER (window), vbox);
-
-  label = gtk_label_new (NULL);
-  gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
-  escaped = g_markup_escape_text (filename, -1);
-  str = g_strdup_printf ("Loaded from file: <b>%s</b>", escaped);
-  gtk_label_set_markup (GTK_LABEL (label),
-                        str);
-  g_free (escaped);
-  g_free (str);
-
-  gtk_box_pack_start (GTK_BOX (vbox), label);
-
-  frame = gtk_frame_new (NULL);
-  gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
-  gtk_widget_set_halign (frame, GTK_ALIGN_CENTER);
-  gtk_widget_set_valign (frame, GTK_ALIGN_CENTER);
-  gtk_box_pack_start (GTK_BOX (vbox), frame);
-
-  image = gtk_image_new_from_file (filename);
-  gtk_container_add (GTK_CONTAINER (frame), image);
-
-  g_signal_connect (window, "destroy",
-                   G_CALLBACK (gtk_main_quit), NULL);
-
-  g_signal_connect (window, "delete_event",
-                   G_CALLBACK (gtk_main_quit), NULL);
-
-  gtk_widget_show (window);
-}
-
-int
-main (int    argc,
-      char **argv)
-{
-  gint i;
-  
-  gtk_init ();
-
-  i = 1;
-  while (i < argc)
-    {
-      do_image (argv[i]);
-      do_nonprogressive (argv[i]);
-      
-      ++i;
-    }
-
-  gtk_main ();
-  
-  return 0;
-}
-